﻿using Loong.Admin.AuditLogging;
using Loong.Admin.Permissions;
using Loong.Admin.Roles;
using Loong.Admin.Users;
using Microsoft.EntityFrameworkCore;
using Volo.Abp.Data;
using Volo.Abp.EntityFrameworkCore;

namespace Loong.Admin.EntityFrameworkCore;

[ConnectionStringName(AdminDbProperties.ConnectionStringName)]
public class AdminDbContext : AbpDbContext<AdminDbContext>
{
    /* Add DbSet for each Aggregate Root here. Example:
     * public DbSet<Question> Questions { get; set; }
     */
    public DbSet<AuditLog> AuditLogs { get; set; }
    public DbSet<AuditLogAction> AuditLogActions { get; set; }
    public DbSet<EntityChange> EntityChanges { get; set; }
    public DbSet<EntityPropertyChange> EntityPropertyChanges { get; set; }
    public DbSet<PermissionGrant> PermissionGrants { get; set; }
    public DbSet<Role> Roles { get; set; }
    public DbSet<User> Users { get; set; }

    public AdminDbContext(DbContextOptions<AdminDbContext> options)
        : base(options)
    {

    }

    protected override void OnModelCreating(ModelBuilder builder)
    {
        base.OnModelCreating(builder);

        builder.ApplyConfigurationsFromAssembly(typeof(AdminEntityFrameworkCoreModule).Assembly);
    }
}
